package com.senven.api.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.senven.api.commom.ResponsePage;
import com.senven.api.dao.StudentMapper;
import com.senven.api.pojo.Student;
import com.senven.api.pojo.Organ;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author YJF
 *
 */
@Service
public class StudentService {
    @Autowired
    private StudentMapper studentMapper;

    public ResponsePage<Student> queryStudentList(int current, int size){
        Page<Student> page = new Page<Student>(current, size);
        QueryWrapper<Student> wrapper = new QueryWrapper<Student>();
        IPage<Student> iPage = studentMapper.selectPage(page, null);
        ResponsePage<Student> responsePage= new ResponsePage<Student>();
        responsePage.makePage(iPage);
        return responsePage;
    }



    /**
     *根据ID查询学生实体
     * @param id
     * @return
     */
    public Student queryStudentListById(String id){
        return studentMapper.queryStudentListById(id);
    }



    /**
     * 插入一个学生实体
     * @param student
     * @return
     */
    public int insertStudent(Student student){return studentMapper.insertStudent(student);};



    /**
     * 更新一个学生实体
     * @param student
     * @return
     */
    public int updateStudent(Student student){return studentMapper.updateStudent(student);}



    /**
     *
     * 删除一个学生实体
     * @param id
     * @return
     */
    public int deleteStudent(String id){return studentMapper.deleteStudent(id);}

}

